package com.pactera.mavenweb.entity;


import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * 
 * @author will
 *
 */
@Entity  
@Table(name="t_role")
public class Role {
	
	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
//	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name = "id", unique = true, nullable=false, length = 20)
	private int id;
	
	@Column(length = 40, nullable=false)
	private String role;
	
	@Column(length = 40, nullable=false)
	private String descpt;
	
	@Column(length = 40, nullable=false)
	private String category;
	
	private Set<UserRole> userRole = new HashSet<UserRole>();
	
	@Id
	@GeneratedValue
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	
	public String getRole() {
		return role;
	}
	public void setRole(String role) {
		this.role = role;
	}
	public String getDescpt() {
		return descpt;
	}
	public void setDescpt(String descpt) {
		this.descpt = descpt;
	}
	public String getCategory() {
		return category;
	}
	public void setCategory(String category) {
		this.category = category;
	}
//	@OneToMany(cascade = { CascadeType.REFRESH, CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REMOVE },mappedBy ="role")
	@OneToMany(cascade = { CascadeType.ALL },mappedBy ="role", fetch = FetchType.LAZY)
	public Set<UserRole> getUserRole() {
		return userRole;
	}
	public void setUserRole(Set<UserRole> userRole) {
		this.userRole = userRole;
	}
}
